package org.design.strategyPattern;

import java.util.List;

/**
 * ShellSort
 *
 * @author 樊温军
 * @date 2025/6/24 上午11:42
 */
public class ShellSortAlgorithm implements AlgorithmStrategy {
    @Override
    public void sort(List<Integer> arr) {
        int len = arr.size();
        for (int gap = len / 2; gap > 0; gap /= 2) {
            for (int i = gap; i < len; i++) {
                int temp = arr.get(i);
                int j = i - gap;
                while (j >= 0 && arr.get(j) > temp) {
                    arr.set(j + gap, arr.get(j));
                    j -= gap;
                }
                arr.set(j + gap, temp);
            }
        }
    }
}
